翻訳と辞書
Words near each other
・ Option Lock
・ Option Musique
・ Option N.V.
・ Option naming convention
・ Option nationale
・ Option Nyahunzvi
・ Option offense
・ Option Paralysis
・ Option pool shuffle
・ Option Québec
・ Option ROM
・ Option screener
・ Option style
・ Option symbol
・ Option time value
Option type
・ Option value (cost–benefit analysis)
・ Option Verdun/Montréal
・ Option Zero
・ Option-adjusted spread
・ Option-operand separation
・ Optional federal charter
・ Optional flex acreage
・ Optional Practical Training
・ Optional preferential voting
・ Optional Protocol on the Involvement of Children in Armed Conflict
・ Optional Protocol on the Sale of Children, Child Prostitution and Child Pornography
・ Optional Protocol to the Convention against Torture
・ Optional Protocol to the Convention on the Elimination of All Forms of Discrimination against Women
・ Optional Protocol to the Convention on the Rights of Persons with Disabilities


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Option type : ウィキペディア英語版
Option type

In programming languages (especially functional programming languages) and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional value; e.g., it is used as the return type of functions which may or may not return a meaningful value when they are applied. It consists of either an empty constructor (called ''None'' or ''Nothing''), or a constructor encapsulating the original data type A (written ''Just'' A or ''Some'' A). Outside of functional programming, these are known as nullable types.
* In the Haskell language, the option type (called ''Maybe'') is defined as .
* In the Idris language, the option type is also defined as .
* In the Agda language, the option type is called Maybe with variants nothing and just a.
* In the Coq language, the option type is defined as .
* In the OCaml language, the option type is defined as type 'a option = None | Some of 'a.
* In the Scala language, the option type is defined as parameterized abstract class '.. Option() = if (x == null) None else Some(x)...
* In the Standard ML language, the option type is defined as datatype 'a option = NONE | SOME of 'a.
* In the Rust language, it is defined as enum Option .
* In the Swift language, it is defined as enum Optional but is generally written as T? and is initialized with either a value or nil.
* In the Julia language, the option type is called Nullable.
* In the Java language since version 8, the option type is defined as parameterized final class Optional.
* In the C++ language proposed extensions, the option type is defined as the template class template class optional.
In type theory, it may be written as: A^ = A + 1.
In languages that have tagged unions, as in most functional programming languages, option types can be expressed as the tagged union of a unit type plus the encapsulated type.
In the Curry-Howard correspondence, option types are related to the annihilation law for ∨: x∨1=1.
An option type can also be seen as a collection containing either a single element or zero elements.
== The option monad ==
The option type is a monad under the following functions:
:\text\colon A \to A^ = a \mapsto \text \, a
:\text\colon A^ \to (A \to B^) \to B^ = a \mapsto f \mapsto \begin \text & \text \ a = \text\\ f \, a' & \text \ a = \text \, a' \end
We may also describe the option monad in terms of functions ''return'', ''fmap'' and ''join'', where the latter two are given by:
:\text \colon (A \to B) \to A^ \to B^ = f \mapsto a \mapsto \begin \text & \text \ a = \text\\ \text \, f \, a' & \text \ a = \text \, a' \end
:\text \colon \to A^ = a \mapsto \begin \text & \text \ a = \text\\ \text & \text \ a = \text \, \text\\ \text \, a' & \text \ a = \text \, \text \, a' \end
The option monad is an additive monad: it has ''Nothing'' as a zero constructor and the following function as a monadic sum:
:\text \colon A^ \to A^ \to A^ = a_1 \mapsto a_2 \mapsto \begin \text & \text \ a_1 = \text \and a_2 = \text\\ \text \, a'_2 & \text \ a_1 = \text \and a_2 = \text \, a'_2 \\ \text \, a'_1 & \text \ a_1 = \text \, a'_1 \end
In fact, the resulting structure is an idempotent monoid.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Option type」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.